const Mysql = require('./mysql.js'),
    sql = new Mysql();
class Api{
    //获取市区数据（开启状态）
    getCityList(callback){
        sql.get("SELECT * FROM city WHERE status=0",(err,result) => {
            callback(result)
        })
    };
    //根据市区ID获取校区列表
    getSchoolListByCity(cityId,callback){
        sql.get("SELECT * FROM school WHERE status=1 and city_id=?",[cityId],(err,result) => {
            callback(result)
        })
    };

    //根据中考成绩获取全市排名
    getCityRankintByScort(scoreFile,callback){
        sql.get("SELECT ranking FROM score_file WHERE fractions=?",[scoreFile],(err,result) => {
            callback(result)
        })
    };

    //根据校排名 区县 学校获取分数
    getGradeByRankCitySchool(spar,callback){
        sql.get("SELECT grade FROM grade WHERE place<=? and city_id=? and school_id=? order by id desc limit 0,1",[spar.place,spar.cityId,spar.schoolId],(err,result) => {
            callback(result)
        })
    };

    //根据模拟分数获取排名
    getMockRankingByScort(score,callback){
        sql.get("SELECT ranking FROM high_score_file WHERE fractions>=? limit 0,1",[score],(err,result) => {
            callback(result)
        })
    };

    //根据ID获取测评结果
    getResult(id,callback){
        sql.get("SELECT result FROM subject WHERE id=?",[id],(err,result) => {
            callback(result)
        })
    };
}
module.exports = Api;

